<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
<title>Insert title here</title>
<link href="../../css/index.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="jdm-toolbar-wrap J-wrap">                
			<div class="jdm-toolbar J-toolbar">                    
				 <div class="jdm-toolbar-panels J-panel">                                             
				</div>                                       
				<div class="jdm-toolbar-tabs J-tab">  
					<div data-type="bar" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-cart">                                
						<i class="tab-ico"></i><a href="${pageContext.request.contextPath}/Carts?userId=${sessionScope.user.userId}">                              <em class="tab-text">购物车                                
						</em>   </a>                                                 
					</div>   
					<div class="J-trigger jdm-toolbar-tab jdm-tbar-tab-message" data-name="message">
					<i class="tab-ico"></i><a href="${pageContext.request.contextPath}/showFavorite?userId=${sessionScope.user.userId}">                                 
					<em class="tab-text">      收藏夹                               
					</em></a>                                               
				</div>                     
			</div>                     
			<div class="jdm-toolbar-footer">                        
				<div data-type="link" id="#top" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-top">                                
					<a href="#" clstag="h|keycount|cebianlan_h|top">                                
						<i class="tab-ico"></i>                                <em class="tab-text">顶部</em>                                
					</a>                         
				</div>                        
				<div data-type="link" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-feedback">                                 
					<a href="http://surveys.jd.com/index.php?r=survey/index/sid/889711/newtest/Y/lang/zh-Hans" target="_blank" clstag="h|keycount|cebianlan_h|feedback">                                    
						<i class="tab-ico"></i>                                    
						<em class="tab-text">反馈</em>                                
					</a>                        
				</div>                        
			</div>                    
			<div class="jdm-toolbar-mini">                    
			</div>                
		</div>                
		<div id="J-toolbar-load-hook" clstag="h|keycount|cebianlan_h|load"></div>            
	</div>
		<!-----------------------------------------顶部-------------->
		<header id="header">
			<div class="header-box">
				<ul class="header-left">
				</ul>
				<ul class="header-right">
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/user/userLogin.jsp">您好，请登录</a> <a href="${pageContext.request.contextPath}/jsp/user/userRegister.jsp"  class="red">免费注册</a></li> 
					<li class="shu"></li>
					<li class="denglu"><a href="#">我的订单</a></li>
					<li class="denglu"><a href="#">我的收藏夹</a></li>
					<li class="denglu"><a href="#">个人中心</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/shop/ShopLogin.jsp">卖家中心</a></li>
					<li class="denglu"><a href="#">客服中心</a></li>
				</ul>
			</div>
		</header>
		<div class="w">
			<div class="logo"><a href=""><img width="100" height= "80" src="./images/logo.png"></a></div>
			<div class="search">
				<input type="text" value="搜索" class="text" id="textt">
				<button class="button" onclick="find()">搜索</button>
			</div>
			<div class="right">
				<i class="gw-left" style="background:url(./images/jd2015img.png)0 -58px no-repeat;width:24px;height:24px;"></i>
				<i class="gw-right">></i>
				<i class="gw-count">0</i>
				<a href="${pageContext.request.contextPath}/Carts?userId=${sessionScope.user.userId}">我的购物车</a>
				<div class="dorpdown-layer">
					<img src="./images/settleup-nogoods.png">
					购物车中还没有商品，赶紧选购吧！
				</div>
			</div>
			<div class="hotwords">
				<a href="#">海苔</a>
				<a href="#">果冻</a>
				<a href="#">饼干</a>
				<a href="#">锅巴</a>
				<a href="#">可乐</a>
			</div>
		</div>
		
		<div class="clear"></div>
<div>
	<h4>选择收货地址</h4>
	<form>
		<div id="showAddress"></div>
		<div style="margin-top: 20px;"><button>新增地址</button></div>
		<hr>	
		<h3>订单详情</h3>
		<div id="orderDetail" style="margin-top: 60px"></div>
	</form>
</div>
<!--***********************************************-->
	<div class="lazy-fn lazy-fn-done" id="lazy-footer">        
		<div id="service-2014">
	<div class="slogen">
		 <img src="images/duo.png" alt="">
	</div>
	<div class="w">
		<dl class="fore1">
			<dt>购物指南</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">购物流程</a></div>
				<div><a rel="nofollow" target="_blank" href="#">会员介绍</a></div>
				<div><a rel="nofollow" target="_blank" href="#">生活旅行/团购</a></div>
				<div><a rel="nofollow" target="_blank" href="#">常见问题</a></div>
				<div><a rel="nofollow" target="_blank" href="#">大家电</a></div>
				<div><a rel="nofollow" target="_blank" href="#">联系客服</a></div>
			</dd>
		</dl>
		<dl class="fore2">		
			<dt>配送方式</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">上门自提</a></div>
				<div><a rel="nofollow" target="_blank" href="#">211限时达</a></div>
				<div><a rel="nofollow" target="_blank" href="#">配送服务查询</a></div>
				<div><a rel="nofollow" target="_blank" href="#">配送费收取标准</a></div>
				<div><a target="_blank" href="#">海外配送</a></div>
			</dd>
		</dl>
		<dl class="fore3">
			<dt>支付方式</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">货到付款</a></div>
				<div><a rel="nofollow" target="_blank" href="#">在线支付</a></div>
				<div><a rel="nofollow" target="_blank" href="#">分期付款</a></div>
				<div><a rel="nofollow" target="_blank" href="#">邮局汇款</a></div>
				<div><a rel="nofollow" target="_blank" href="#">公司转账</a></div>
			</dd>
		</dl>
		<dl class="fore4">		
			<dt>售后服务</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">售后政策</a></div>
				<div><a rel="nofollow" target="_blank" href="#">价格保护</a></div>
				<div><a rel="nofollow" target="_blank" href="#">退款说明</a></div>
				<div><a rel="nofollow" target="_blank" href="#">返修/退换货</a></div>
				<div><a rel="nofollow" target="_blank" href="#">取消订单</a></div>
			</dd>
		</dl>
		<dl class="fore5">
			<dt>特色服务</dt>
			<dd>		
				<div><a target="_blank" href="#">夺宝岛</a></div>
				<div><a target="_blank" href="#">DIY装机</a></div>
				<div><a rel="nofollow" target="_blank" href="#">延保服务</a></div>
				<div><a rel="nofollow" target="_blank" href="#">京东E卡</a></div>	
				<div><a rel="nofollow" target="_blank" href="#">京东通信</a></div>
				<div><a rel="nofollow" target="_blank" href="#">京东JD+</a></div>
			</dd>
		</dl>
		<div id="coverage">
			<div class="dt">
				京东自营覆盖区县
			</div>
			<div class="dd">
				<p>京东已向全国2423个区县提供自营配送服务，支持货到付款、POS机刷卡和售后上门服务。</p>
				<p class="ar"><a target="_blank" href="http://help.jd.com/user/issue/103-983.html">查看详情&nbsp;&gt;</a></p>
			</div>
		</div>
		<span class="clr"></span>
	</div>
</div>        <div class="w">
	<div id="footer-2014" >
		<div class="links">
			<a rel="nofollow" target="_blank" href="#">关于我们</a>|<a  href="#">联系我们</a>|<a rel="nofollow" target="_blank" href="#">商家入驻</a>|<a rel="nofollow" target="_blank" href="#">营销中心</a>|<a rel="nofollow" target="_blank" href="#">手机京东</a>|<a target="_blank" href="#">友情链接</a>|<a target="_blank" href="#">销售联盟</a>|<a href="#" target="_blank">京东社区</a>|<a href="#" target="_blank">京东公益</a>|<a href="#" target="_blank">English Site</a>|<a href="#" target="_blank">Contact Us</a></div>
		<div class="copyright">
			<a target="_blank" href="#"><img src="images/56a0a994Nf1b662dc.png"> 京公网安备 11000002000088号</a>&nbsp;&nbsp;|&nbsp;&nbsp;京ICP证070359号&nbsp;&nbsp;|&nbsp;&nbsp;<a target="_blank" href="#">互联网药品信息服务资格证编号(京)-经营性-2014-0008</a>&nbsp;&nbsp;|&nbsp;&nbsp;新出发京零&nbsp;字第大120007号<br><a rel="nofollow" href="#" target="_blank">音像制品经营许可证苏宿批005号</a>&nbsp;&nbsp;|&nbsp;&nbsp;出版物经营许可证编号新出发(苏)批字第N-012号&nbsp;&nbsp;|&nbsp;&nbsp;互联网出版许可证编号新出网证(京)字150号<br><a href="#" target="_blank">网络文化经营许可证京网文[2014]2148-348号</a>&nbsp;&nbsp;违法和不良信息举报电话：4006561155&nbsp;&nbsp;Copyright&nbsp;©&nbsp;2004-2016&nbsp;&nbsp;京东JD.com&nbsp;版权所有<br>京东旗下网站：<a target="_blank" href="http://www.360top.com/">360TOP</a>&nbsp;&nbsp;<a href="#" target="_blank">拍拍网</a>&nbsp;&nbsp;<a href="#" target="_blank">网银在线</a></div>
		
		<div class="authentication">
			<a rel="nofollow" target="_blank" href="#">
				<img width="103" height="32" alt="经营性网站备案中心" src="images/54b8871eNa9a7067e.png" class="err-product">
			</a>
			
			<a rel="nofollow" target="_blank" id="urlknet" tabindex="-1" href="#">
				<img border="true" width="103" height="32" onclick="CNNIC_change('urlknet')" oncontextmenu="return false;" name="CNNIC_seal" alt="可信网站" src="images/54b8872dNe37a9860.png" class="err-product">
			</a>
			<a rel="nofollow" target="_blank" href="#">
				<img width="103" height="32" alt="网络警察" src="images/56a89b8fNfbaade9a.jpg" class="err-product">
			</a>
			<a rel="nofollow" target="_blank" href="#">
				<img width="103" height="32" src="images/54b8875fNad1e0c4c.png" class="err-product">
			</a>
			<a target="_blank" href="#"><img width="103" height="32" src="images/5698dc03N23f2e3b8.jpg"></a>
			<a target="_blank" href="#"><img width="103" height="32" src="images/5698dc16Nb2ab99df.jpg"></a>
		</div>
	  </div>
    </div>
  </div>
</body>
<script type="text/javascript">
	var goodsId = ${order.goodsId};
	var orderNum = ${order.orderNum};
	queryAddress();
	function queryAddress(){
		var userId = "${user.userId}";
		//var userId = 1;
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/queryAddress",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				userId:userId
				},
			success:function(data){
				var str = "";
				for(var i = 0;i<data.length;i++){
					str += "<input type='radio' name='orderAddress' value='"+data[i].addressName+"' id='orderAddress'>"+data[i].addressName;
				}
				str += "</form>";
				$("#showAddress").html(str);
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}
	orderDetail();
	function orderDetail(){
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/orderDetail",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				goodsId:goodsId
				},
			success:function(data){
				var str = "<table width='800px'><tr><th>商品名称</th><th>商品类型</th><th>单价</th><th>数量</th><th>总计</th></tr>";
				str += "<tr><td align='center'>"+data[0].goodsName+"</td><td align='center'>"+data[0].goodsType+"</td><td align='center'>"+data[0].goodsPrice+"</td><td align='center'>"+orderNum+"</td><td align='center'>"+orderNum*data[0].goodsPrice+"</td>";
				str += "</tr></table>";
				str += "<div align='right' style='margin-top: 60px'><button style='width:200px;height:45px;font-family:'Microsoft yahei';font-size:20px;background:#f60;color:#fff;border:none;' onclick='buy("+data[0].goodsId+","+orderNum+")'>付款</button>";
				$("#orderDetail").html(str);
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}
	function buy(goodsId,orderNum){
		//var userId = 1;
		var userId = "${user.userId}";
		var orderAddress = document.getElementById('orderAddress').value;
		if(orderAddress == null){
			alert("请选择送货地址！");
		}
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/buyGoods",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				goodsId:goodsId,
				orderNum:orderNum,
				userId:userId,
				orderAddress:orderAddress
				},
			success:function(data){
				if(data == 2){
					alert("购买成功");
				}else{
					alert("购买失败");
				}
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}
	
	function find(){
		window.location.href='http://localhost:8080/jsp/user/findGoods.jsp';
	} 
</script>
</html>